package net.wanho.controller;

import com.alibaba.fastjson.JSON;
import net.wanho.entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.HashMap;
import java.util.Properties;

/**
 * Author：汤小洋
 * Date：2023-08-07 15:30
 * Description：<描述>
 */
@WebServlet("/hello")
public class HelloController extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("hello.............");

        Properties p = new Properties();
        p.load(HelloController.class.getClassLoader().getResourceAsStream("datasource.properties"));
        System.out.println(p);

        User user = new User(1, "张三", 18, "男性", 180.4, new Date());

        resp.setContentType("application/json;charset=utf-8");
        PrintWriter out = resp.getWriter();
        out.print(JSON.toJSONString(user));
        out.close();
    }
}
